<?php
function phpmail($subject,$body,$to,$toname,$num,$attach){
	$mail_conf=require("./mail.config.php");
	require_once("./phpmailer/class.phpmailer.php");
	$mail = new PHPMailer();
	$mail->ClearAllRecipients();
	$mail->CharSet = "UTF-8"; 
	$mail->IsSMTP();
	$mail->IsHTML(true);
	$mail->SMTPAuth   = true;                  
	//$mail->Port       = 587;      //587,465
	//$mail->SMTPSecure = 'tls'; //ssl tls
	$mail->Host       = $mail_conf['smtp_host'];
	$mail->Username   = $mail_conf['username'];
	$mail->Password   = $mail_conf['password'];
	$mail->From= $mail_conf['from'];
	$mail->FromName =$mail_conf['fromname'];
	$mail->AddAddress($to, $toname);
	$mail->Subject = $subject." <ID:".$num.">";
	if(preg_match("/attach::attach/",$attach)){
		$attaches_pmb=explode("attach::attach",$attach);
		array_pop($attaches_pmb);
		foreach($attaches_pmb as $v){
			$mail->AddAttachment("./imap/example/attachments/".$num."/".trim($v));
		}
	}else{
		$mail->AddAttachment("./imap/example/attachments/".$num."/".$attach);
	}
	$mail->Body=":: Reply above this line to post a reply ::<br><hr>" .$body;
	if(!$mail->Send()) {
	  echo "Mailer Error: " . $mail->ErrorInfo;
	}
}
?>